<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/snowzhao/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/snowzhao/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/snowzhao/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/snowzhao/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/snowzhao/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/snowzhao/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/snowzhao/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="android,">










<meta name="description" content="前沿我们正常项目使用原生webview加载h5页面也是没问题的，但是当使用原生webview加载h5出问题了，h5地址在微信等可以正常使用，前端就会丢锅给我们，为了杜绝不是我们Android的问题，那我们也集成TBS浏览器X5内核替换原生webview。。。 腾讯的TBS浏览器X5内核（文章中统一简称X5内核）的优点直接看文档介绍就有，文章主要将集成点和加载X5内核失败怎么解决、在应用内打开pdf">
<meta name="keywords" content="android">
<meta property="og:type" content="article">
<meta property="og:title" content="使用腾讯的TBS浏览器X5内核的集成加载pdf等文件">
<meta property="og:url" content="https://vincent_zyt.gitee.io/snowzhao/2019/09/04/TBS浏览器X5内核使用/index.html">
<meta property="og:site_name" content="snowzhao博客">
<meta property="og:description" content="前沿我们正常项目使用原生webview加载h5页面也是没问题的，但是当使用原生webview加载h5出问题了，h5地址在微信等可以正常使用，前端就会丢锅给我们，为了杜绝不是我们Android的问题，那我们也集成TBS浏览器X5内核替换原生webview。。。 腾讯的TBS浏览器X5内核（文章中统一简称X5内核）的优点直接看文档介绍就有，文章主要将集成点和加载X5内核失败怎么解决、在应用内打开pdf">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://vincent_zyt.gitee.io/uploads/20190904001.png">
<meta property="og:image" content="https://vincent_zyt.gitee.io/uploads/20190904002.png">
<meta property="og:image" content="https://vincent_zyt.gitee.io/uploads/20190904003.png">
<meta property="og:updated_time" content="2019-09-04T08:39:41.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="使用腾讯的TBS浏览器X5内核的集成加载pdf等文件">
<meta name="twitter:description" content="前沿我们正常项目使用原生webview加载h5页面也是没问题的，但是当使用原生webview加载h5出问题了，h5地址在微信等可以正常使用，前端就会丢锅给我们，为了杜绝不是我们Android的问题，那我们也集成TBS浏览器X5内核替换原生webview。。。 腾讯的TBS浏览器X5内核（文章中统一简称X5内核）的优点直接看文档介绍就有，文章主要将集成点和加载X5内核失败怎么解决、在应用内打开pdf">
<meta name="twitter:image" content="https://vincent_zyt.gitee.io/uploads/20190904001.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/snowzhao/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://vincent_zyt.gitee.io/snowzhao/2019/09/04/TBS浏览器X5内核使用/">





  <title>使用腾讯的TBS浏览器X5内核的集成加载pdf等文件 | snowzhao博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/snowzhao/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">snowzhao博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">蜕变</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-首页">
          <a href="/snowzhao/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-归档">
          <a href="/snowzhao/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-标签">
          <a href="/snowzhao/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-分类">
          <a href="/snowzhao/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://vincent_zyt.gitee.io/snowzhao/snowzhao/2019/09/04/TBS浏览器X5内核使用/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="snowzhao">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/snowzhao/images/photo.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="snowzhao博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">使用腾讯的TBS浏览器X5内核的集成加载pdf等文件</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-09-04T16:39:41+08:00">
                2019-09-04
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/snowzhao/categories/android/" itemprop="url" rel="index">
                    <span itemprop="name">android</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.3k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  5
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="前沿"><a href="#前沿" class="headerlink" title="前沿"></a>前沿</h3><p>我们正常项目使用原生webview加载h5页面也是没问题的，但是当使用原生webview加载h5出问题了，h5地址在微信等可以正常使用，前端就会丢锅给我们，为了杜绝不是我们Android的问题，那我们也集成TBS浏览器X5内核替换原生webview。。。</p>
<p>腾讯的TBS浏览器X5内核（文章中统一简称X5内核）的优点直接看文档介绍就有，文章主要将集成点和加载X5内核失败怎么解决、在应用内打开pdf等文件的功能（此功能官方文档没有）；关于官方文档和sdk下载看下面链接：</p>
<p><a href="https://x5.tencent.com/tbs/guide/sdkInit.html" target="_blank" rel="noopener">腾讯TBS官网接入步骤</a><br><a href="https://x5.tencent.com/tbs/sdk.html" target="_blank" rel="noopener">SDK下载</a><br><a href="https://x5.tencent.com/tbs/technical.html#/sdk" target="_blank" rel="noopener">TBS浏览服务SDK接入问题</a><br><a href="https://github.com/zhaoyingtao/X5WebViewDemo" target="_blank" rel="noopener">github集成Demo</a></p>
<h3 id="一、集成（Android-studio-依赖库集成）"><a href="#一、集成（Android-studio-依赖库集成）" class="headerlink" title="一、集成（Android studio  依赖库集成）"></a>一、集成（Android studio  依赖库集成）</h3><p>关于jar包集成方法自行参考文档或者百度吧！</p>
<h4 id="1、在app的build-gradle中添加"><a href="#1、在app的build-gradle中添加" class="headerlink" title="1、在app的build.gradle中添加"></a>1、在app的build.gradle中添加</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dependencies &#123;    </span><br><span class="line">    //x5内核Sdk=====在下载sdk说明处有直接复制    </span><br><span class="line">    api &apos;com.tencent.tbs.tbssdk:sdk:43697&apos;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="2、在application类中添加："><a href="#2、在application类中添加：" class="headerlink" title="2、在application类中添加："></a>2、在application类中添加：</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">//下载x5内核，可以不需要，因为会共用其他软件的x5内核，比如微信、QQ等         </span><br><span class="line">         QbSdk.setDownloadWithoutWifi(true);</span><br><span class="line"> </span><br><span class="line">        QbSdk.initX5Environment(this, new QbSdk.PreInitCallback() &#123;</span><br><span class="line">            @Override</span><br><span class="line">            public void onCoreInitFinished() &#123;</span><br><span class="line">                Log.e(&quot;snow&quot;, &quot;========onCoreInitFinished===&quot;);</span><br><span class="line">            &#125;</span><br><span class="line"> </span><br><span class="line">            @Override</span><br><span class="line">            public void onViewInitFinished(boolean b) &#123;</span><br><span class="line">            //加载x5内核成功返回值为true，否则返回false，加载失败会调用系统的webview</span><br><span class="line">                Log.e(&quot;snow&quot;, &quot;x5初始化结果====&quot; + b);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;);</span><br></pre></td></tr></table></figure>

<h4 id="3、在AndroidManifest-xml文件中配置："><a href="#3、在AndroidManifest-xml文件中配置：" class="headerlink" title="3、在AndroidManifest.xml文件中配置："></a>3、在AndroidManifest.xml文件中配置：</h4>  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;</span><br><span class="line">&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;</span><br><span class="line">&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;</span><br><span class="line">&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;</span><br><span class="line">&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;</span><br><span class="line">&lt;!-- 硬件加速对X5视频播放非常重要，建议开启 --&gt;</span><br><span class="line">&lt;uses-permission android:name=&quot;android.permission.GET_TASKS&quot;/&gt;</span><br><span class="line">&lt;application</span><br><span class="line">    android:usesCleartextTraffic=&quot;true&quot;</span><br><span class="line">    android:hardwareAccelerated=&quot;true&quot;&gt;</span><br><span class="line"> </span><br><span class="line">&lt;/application&gt;</span><br></pre></td></tr></table></figure>

<h4 id="4、使用x5内核的webview替换原生webview，使用方法一致，这里就不贴代码了，可以直接去demo中查看"><a href="#4、使用x5内核的webview替换原生webview，使用方法一致，这里就不贴代码了，可以直接去demo中查看" class="headerlink" title="4、使用x5内核的webview替换原生webview，使用方法一致，这里就不贴代码了，可以直接去demo中查看"></a>4、使用x5内核的webview替换原生webview，使用方法一致，这里就不贴代码了，可以直接去demo中查看</h4><p>到这里就集成完成了，运行查看application是否返回true，要是返回true那恭喜你很顺利完成了集成，要是返回false，那继续往下看</p>
<h3 id="二、集成遇到的问题排查："><a href="#二、集成遇到的问题排查：" class="headerlink" title="二、集成遇到的问题排查："></a>二、集成遇到的问题排查：</h3><h4 id="1、使用写的webview加载链接："><a href="#1、使用写的webview加载链接：" class="headerlink" title="1、使用写的webview加载链接："></a>1、使用写的webview加载链接：</h4><p><a href="http://soft.imtt.qq.com/browser/tes/feedback.html" target="_blank" rel="noopener">http://soft.imtt.qq.com/browser/tes/feedback.html</a><br>显示结果000000表示加载的是系统内核，显示大于零的数字表示加载了x5内核（该数字是x5内核版本号）</p>
<h4 id="2、使用-写的webview加载链接："><a href="#2、使用-写的webview加载链接：" class="headerlink" title="2、使用 写的webview加载链接："></a>2、使用 写的webview加载链接：</h4><p><a href="http://debugtbs.qq.com" target="_blank" rel="noopener">http://debugtbs.qq.com</a></p>
<h5 id="2-1、加载成功如下图"><a href="#2-1、加载成功如下图" class="headerlink" title="2.1、加载成功如下图"></a>2.1、加载成功如下图</h5><p><img src="/uploads/20190904001.png" alt></p>
<h5 id="2-2、加载失败提示：请检查网络是否可用"><a href="#2-2、加载失败提示：请检查网络是否可用" class="headerlink" title="2.2、加载失败提示：请检查网络是否可用"></a>2.2、加载失败提示：请检查网络是否可用</h5><p>你的手机应该是9.0以上的系统：google从Android 9.0开始，默认情况下禁用明文支持。因此http的url均无法在webview中加载</p>
<p>在AndroidManifest.xml添加属性</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">android:usesCleartextTraffic=&quot;true&quot;   如下：</span><br><span class="line"></span><br><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;manifest ...&gt;</span><br><span class="line">    &lt;application</span><br><span class="line">        android:usesCleartextTraffic=&quot;true&quot;</span><br><span class="line">        ...&gt;</span><br><span class="line">    &lt;/application&gt;</span><br><span class="line">&lt;/manifest&gt;</span><br></pre></td></tr></table></figure>

<h4 id="3、记载自测链接成功后，最好先点击“安装线上内核”下载内核，然后重启页面后点击“合作方加载检测”，查看提示："><a href="#3、记载自测链接成功后，最好先点击“安装线上内核”下载内核，然后重启页面后点击“合作方加载检测”，查看提示：" class="headerlink" title="3、记载自测链接成功后，最好先点击“安装线上内核”下载内核，然后重启页面后点击“合作方加载检测”，查看提示："></a>3、记载自测链接成功后，最好先点击“安装线上内核”下载内核，然后重启页面后点击“合作方加载检测”，查看提示：</h4><h5 id="3-1、加载内核成功："><a href="#3-1、加载内核成功：" class="headerlink" title="3.1、加载内核成功："></a>3.1、加载内核成功：</h5><p><img src="/uploads/20190904002.png" alt></p>
<h5 id="3-2、加载失败检测原因：如：下面这个提示就是64位手机不能加载x5内核，x5内核目前只支持32位"><a href="#3-2、加载失败检测原因：如：下面这个提示就是64位手机不能加载x5内核，x5内核目前只支持32位" class="headerlink" title="3.2、加载失败检测原因：如：下面这个提示就是64位手机不能加载x5内核，x5内核目前只支持32位"></a>3.2、加载失败检测原因：如：下面这个提示就是64位手机不能加载x5内核，x5内核目前只支持32位</h5><p><img src="/uploads/20190904003.png" alt></p>
<p>x5内核不支持64位的解决方法:<br><a href="https://x5.tencent.com/tbs/technical.html#/detail/sdk/1/34cf1488-7dc2-41ca-a77f-0014112bcab7" target="_blank" rel="noopener">官方关于x5内核64位手机不能使用解决方案</a></p>
<p>出现其他问题都可以通过上述流程检测查看哪里出了问题；</p>
<h3 id="三、关于使用x5内核加载pdf等文件"><a href="#三、关于使用x5内核加载pdf等文件" class="headerlink" title="三、关于使用x5内核加载pdf等文件"></a>三、关于使用x5内核加载pdf等文件</h3><h4 id="几点重要提示："><a href="#几点重要提示：" class="headerlink" title="几点重要提示："></a>几点重要提示：</h4><p>1、加载文件核心类是 TbsReaderView，腾讯文档没有写，TbsReaderView建议通过动态创建，不要使用xml中引用；</p>
<p>2、TBS目前只支持加载本地文件。所以远程文件需要先下载，后用TBS加载文件显示；</p>
<p>3、加载文件的界面，离开本界面之后务必销毁TbsReaderView，否则再次加载文件无法加载成功，会一直显示加载文件进度条；代码如下：tbsReaderView.onStop();</p>
<p>加载文件我直接贴代码了</p>
<h4 id="重点核心代码："><a href="#重点核心代码：" class="headerlink" title="重点核心代码："></a>重点核心代码：</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line">private void openFile() &#123;</span><br><span class="line">    File file = new File(url);</span><br><span class="line">    if (!file.exists()) &#123;</span><br><span class="line">        Toast.makeText(this, &quot;文件不存在&quot;, Toast.LENGTH_LONG).show();</span><br><span class="line">    &#125;</span><br><span class="line">    Bundle bundle = new Bundle();</span><br><span class="line">    bundle.putString(&quot;filePath&quot;, url);</span><br><span class="line">    bundle.putString(&quot;tempPath&quot;, Environment.getExternalStorageDirectory().getPath());</span><br><span class="line">    boolean result = tbsReaderView.preOpen(parseFormat(parseName(url)), false);</span><br><span class="line">    if (result) &#123;</span><br><span class="line">        tbsReaderView.openFile(bundle);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line">private String parseFormat(String fileName) &#123;</span><br><span class="line">    return fileName.substring(fileName.lastIndexOf(&quot;.&quot;) + 1);</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line">private String parseName(String url) &#123;</span><br><span class="line">    String fileName = null;</span><br><span class="line">    try &#123;</span><br><span class="line">        fileName = url.substring(url.lastIndexOf(&quot;/&quot;) + 1);</span><br><span class="line">    &#125; finally &#123;</span><br><span class="line">        if (TextUtils.isEmpty(fileName)) &#123;</span><br><span class="line">            fileName = String.valueOf(System.currentTimeMillis());</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    return fileName;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line">TbsReaderView.ReaderCallback readerCallback = new TbsReaderView.ReaderCallback() &#123;</span><br><span class="line">    @Override</span><br><span class="line">    public void onCallBackAction(Integer integer, Object o, Object o1) &#123;</span><br><span class="line"> </span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">@Override</span><br><span class="line">protected void onDestroy() &#123;</span><br><span class="line">    super.onDestroy();</span><br><span class="line">    //销毁界面的时候一定要加上，否则后面加载文件会发生异常。</span><br><span class="line">    tbsReaderView.onStop();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="调用代码："><a href="#调用代码：" class="headerlink" title="调用代码："></a>调用代码：</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">tbsReaderView = new TbsReaderView(this, readerCallback);</span><br><span class="line"> </span><br><span class="line">  rlRoot.addView(tbsReaderView, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));</span><br><span class="line"> </span><br><span class="line"> openFile();</span><br></pre></td></tr></table></figure>

<p>到此完成了x5内核的集成和打开文件的功能！感觉有用给一个star支持下！</p>
<p><a href="https://github.com/zhaoyingtao/X5WebViewDemo" target="_blank" rel="noopener">demo地址</a><br>————————————————</p>

      
    </div>
    
    
    

 
<div>
  
    <div>
    
        <div style="text-align:center;color: #666;font-size:16px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
  
</div>

    

    

    
    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/snowzhao/tags/android/" rel="tag"># android</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/snowzhao/2019/08/07/qr_code/" rel="next" title="一行代码实现二维码相关功能">
                <i class="fa fa-chevron-left"></i> 一行代码实现二维码相关功能
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/snowzhao/2019/12/02/自定义打卡日历/" rel="prev" title="自定义打卡日历">
                自定义打卡日历 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/snowzhao/images/photo.png" alt="snowzhao">
            
              <p class="site-author-name" itemprop="name">snowzhao</p>
              <p class="site-description motion-element" itemprop="description">给自己每天浇点水,迟早会长成一棵大树</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/snowzhao/archives">
              
                  <span class="site-state-item-count">11</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/snowzhao/categories/index.html">
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/snowzhao/tags/index.html">
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/zhaoyingtao" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/qq_31796651" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-stack-overflow"></i>CSDN</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#前沿"><span class="nav-text">前沿</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#一、集成（Android-studio-依赖库集成）"><span class="nav-text">一、集成（Android studio  依赖库集成）</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1、在app的build-gradle中添加"><span class="nav-text">1、在app的build.gradle中添加</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2、在application类中添加："><span class="nav-text">2、在application类中添加：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3、在AndroidManifest-xml文件中配置："><span class="nav-text">3、在AndroidManifest.xml文件中配置：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4、使用x5内核的webview替换原生webview，使用方法一致，这里就不贴代码了，可以直接去demo中查看"><span class="nav-text">4、使用x5内核的webview替换原生webview，使用方法一致，这里就不贴代码了，可以直接去demo中查看</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#二、集成遇到的问题排查："><span class="nav-text">二、集成遇到的问题排查：</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1、使用写的webview加载链接："><span class="nav-text">1、使用写的webview加载链接：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2、使用-写的webview加载链接："><span class="nav-text">2、使用 写的webview加载链接：</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#2-1、加载成功如下图"><span class="nav-text">2.1、加载成功如下图</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-2、加载失败提示：请检查网络是否可用"><span class="nav-text">2.2、加载失败提示：请检查网络是否可用</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3、记载自测链接成功后，最好先点击“安装线上内核”下载内核，然后重启页面后点击“合作方加载检测”，查看提示："><span class="nav-text">3、记载自测链接成功后，最好先点击“安装线上内核”下载内核，然后重启页面后点击“合作方加载检测”，查看提示：</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#3-1、加载内核成功："><span class="nav-text">3.1、加载内核成功：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3-2、加载失败检测原因：如：下面这个提示就是64位手机不能加载x5内核，x5内核目前只支持32位"><span class="nav-text">3.2、加载失败检测原因：如：下面这个提示就是64位手机不能加载x5内核，x5内核目前只支持32位</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#三、关于使用x5内核加载pdf等文件"><span class="nav-text">三、关于使用x5内核加载pdf等文件</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#几点重要提示："><span class="nav-text">几点重要提示：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#重点核心代码："><span class="nav-text">重点核心代码：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#调用代码："><span class="nav-text">调用代码：</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">snowzhao</span>

<!-- 取消英文统计数字
  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">7.4k</span>
  
-->
</div>
<!-- 取消默认 由 hexo 强力驱动 | 主题 next。pisces v5.1.4

  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>



-->



<span class="post-meta-divider"> 坚持 </span>

<span class="post-meta-divider"> | </span>

<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共 7.4k 字</span>
</div>

        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/snowzhao/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/snowzhao/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/snowzhao/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/snowzhao/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/snowzhao/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/snowzhao/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/snowzhao/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/snowzhao/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

<script src="/snowzhao/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/snowzhao/live2dw/assets/assets/z16.model.json"},"display":{"position":"right","width":300,"height":500},"mobile":{"show":false},"log":false});</script></body>
</html>
